package com.ruoyi.hr.controller.hr.bginfo;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.service.AuthorityService;
import com.ruoyi.hr.service.bginfo.DetailedEmpInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author zeo
 * @explain 员工详细信息
 * @date 2020/3/27
 */

@Controller
@RequestMapping("/bgInfo/detailedEmpInfo")
public class DetailedEmpInfoController extends BaseController {

    @Autowired
    AuthorityService authorityService;

    @Autowired
    DetailedEmpInfoService detailedEmpInfoService;

    private String prefix = "hr/bginfo/detailedempinfo";

    /**
     * 跳转分页页面
     */
    @GetMapping()
    public String detailedEmpInfo() {
        return prefix + "/detailedEmpInfo";
    }

    @RequestMapping("/findDataList")
    @ResponseBody
    public TableDataInfo findDataList(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        return getDataTable(detailedEmpInfoService.findDataList(map, authority));
    }

    @GetMapping("/edit/{eid}")
    public String edit(@PathVariable("eid") String eid, ModelMap mmap) {
        mmap.put("emp", detailedEmpInfoService.findDataByEid(eid));
        return prefix + "/edit";
    }

    @RequestMapping("/edit")
    @ResponseBody
    public AjaxResult edit(@RequestParam Map map){
        return toAjax(detailedEmpInfoService.edit(map));
    }
}
